package Object;

public class Capsulation {
    //合理隐藏
    private String name;
    private int age;
    private int gender;
    //合理暴露
    public void setAge(int age){
        if (age>0&&age<200){
            this.age=age;
        }else {
            System.out.println("输入错误");
        }
    }
    public int getAge(){
        System.out.println(age);
        return age;
    }
}
